package bio.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * @author Huhailong
 * @Description time client
 * @Date 2021/4/8.
 */
public class TimeClient2 {

    public static void main(String[] args) {
        int port = 8080;
        try (
                Socket socket = new Socket("127.0.0.1", port);
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                PrintWriter out = new PrintWriter(socket.getOutputStream(), true)
        ) {
            int count = 1;  
            while (count < 11) {
                out.println("QUERY CURRENT TIME " + count);
                System.out.println("TIME CLIENT: SEND MESSAGE SUCCESS " + count);
                System.out.println("Current Time is :" + in.readLine());
                Thread.sleep(1000L);
                count++;
            }


        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
